import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {SideMenuService} from "../../../services/common/side-menu.service";
import {BeneficiaryDetail} from "../../../model/pages/policy/policy-detail/beneficiary";
import * as moment from 'moment';
import {ToastService} from "../../../services/common/toast.service";

/**
 * Generated class for the BeneficiaryDetailPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
    selector: 'page-beneficiary-detail',
    templateUrl: 'beneficiary-detail.html',
    providers: [SideMenuService, ToastService]
})
export class BeneficiaryDetailPage {
    /**
     * 受益人数据
     * @type {BeneficiaryDetail}
     */
    beneficiaryDetail: BeneficiaryDetail = new BeneficiaryDetail();
    /**
     * 序号
     * @type {null}
     */
    index = null;

    moment = moment;

    constructor(
        public navCtrl: NavController,
        public navParams: NavParams,
        private toast: ToastService,
        private sideMenuService: SideMenuService,) {
    }

    ionViewDidLoad() {
        // console.log('ionViewDidLoad BeneficiaryDetailPage');
        // 获取受益人数据
        this.beneficiaryDetail = this.navParams.get('beneficiary');

        if (!this.beneficiaryDetail) {
            this.toast.showToast('请求数据为空');
        }

        console.log(this.beneficiaryDetail);
        // 获取受益人序号
        this.index = this.navParams.get('index');


    }

    /**
     * 返回上一级
     */
    goBack() {
        this.navCtrl.pop();
    }


    openMenu(myEvent) {
        this.sideMenuService.openSideMenu(myEvent);
    }


}
